<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QSslCertificate Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QSslCertificate Class Reference<br /><sup><sup>[<a href="qtnetwork.html">QtNetwork</a> module]</sup></sup></h1><p>The QSslCertificate class provides a convenient API for an X509
certificate. <a href="#details">More...</a></p>

<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qsslcertificate.html#SubjectInfo-enum">SubjectInfo</a></b> { Organization, CommonName, LocalityName, OrganizationalUnitName, CountryName, StateOrProvinceName }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qsslcertificate.html#QSslCertificate">__init__</a></b> (<i>self</i>, QIODevice&#160;<i>device</i>, QSsl.EncodingFormat&#160;<i>format</i>&#160;=&#160;QSsl.Pem)</li><li><div class="fn" /><b><a href="qsslcertificate.html#QSslCertificate-2">__init__</a></b> (<i>self</i>, QByteArray&#160;<i>data</i>&#160;=&#160;QByteArray(), QSsl.EncodingFormat&#160;<i>format</i>&#160;=&#160;QSsl.Pem)</li><li><div class="fn" /><b><a href="qsslcertificate.html#QSslCertificate-3">__init__</a></b> (<i>self</i>, QSslCertificate&#160;<i>other</i>)</li><li><div class="fn" />dict-of-QSsl.AlternateNameEntryType-list-of-QString <b><a href="qsslcertificate.html#alternateSubjectNames">alternateSubjectNames</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsslcertificate.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray <b><a href="qsslcertificate.html#digest">digest</a></b> (<i>self</i>, QCryptographicHash.Algorithm&#160;<i>algorithm</i>&#160;=&#160;QCryptographicHash.Md5)</li><li><div class="fn" />QDateTime <b><a href="qsslcertificate.html#effectiveDate">effectiveDate</a></b> (<i>self</i>)</li><li><div class="fn" />QDateTime <b><a href="qsslcertificate.html#expiryDate">expiryDate</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qsslcertificate.html#handle">handle</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsslcertificate.html#isNull">isNull</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qsslcertificate.html#issuerInfo">issuerInfo</a></b> (<i>self</i>, SubjectInfo&#160;<i>info</i>)</li><li><div class="fn" />QString <b><a href="qsslcertificate.html#issuerInfo-2">issuerInfo</a></b> (<i>self</i>, QByteArray&#160;<i>tag</i>)</li><li><div class="fn" />bool <b><a href="qsslcertificate.html#isValid">isValid</a></b> (<i>self</i>)</li><li><div class="fn" />QSslKey <b><a href="qsslcertificate.html#publicKey">publicKey</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray <b><a href="qsslcertificate.html#serialNumber">serialNumber</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qsslcertificate.html#subjectInfo">subjectInfo</a></b> (<i>self</i>, SubjectInfo&#160;<i>info</i>)</li><li><div class="fn" />QString <b><a href="qsslcertificate.html#subjectInfo-2">subjectInfo</a></b> (<i>self</i>, QByteArray&#160;<i>tag</i>)</li><li><div class="fn" />QByteArray <b><a href="qsslcertificate.html#toDer">toDer</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray <b><a href="qsslcertificate.html#toPem">toPem</a></b> (<i>self</i>)</li><li><div class="fn" />QByteArray <b><a href="qsslcertificate.html#version">version</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />list-of-QSslCertificate <b><a href="qsslcertificate.html#fromData">fromData</a></b> (QByteArray&#160;<i>data</i>, QSsl.EncodingFormat&#160;<i>format</i>&#160;=&#160;QSsl.Pem)</li><li><div class="fn" />list-of-QSslCertificate <b><a href="qsslcertificate.html#fromDevice">fromDevice</a></b> (QIODevice&#160;<i>device</i>, QSsl.EncodingFormat&#160;<i>format</i>&#160;=&#160;QSsl.Pem)</li><li><div class="fn" />list-of-QSslCertificate <b><a href="qsslcertificate.html#fromPath">fromPath</a></b> (QString&#160;<i>path</i>, QSsl.EncodingFormat&#160;<i>format</i>&#160;=&#160;QSsl.Pem, QRegExp.PatternSyntax&#160;<i>syntax</i>&#160;=&#160;QRegExp.FixedString)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qsslcertificate.html#__eq__">__eq__</a></b> (<i>self</i>, QSslCertificate&#160;<i>other</i>)</li><li><div class="fn" />bool <b><a href="qsslcertificate.html#__ne__">__ne__</a></b> (<i>self</i>, QSslCertificate&#160;<i>other</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QSslCertificate class provides a convenient API for an X509
certificate.</p>
<p>QSslCertificate stores an X509 certificate, and is commonly used
to verify the identity and store information about the local host,
a remotely connected peer, or a trusted third party Certificate
Authority.</p>
<p>There are many ways to construct a QSslCertificate. The most
common way is to call <a href="qsslsocket.html#peerCertificate">QSslSocket.peerCertificate</a>(),
which returns a QSslCertificate object, or <a href="qsslsocket.html#peerCertificateChain">QSslSocket.peerCertificateChain</a>(),
which returns a list of them. You can also load certificates from a
DER (binary) or PEM (Base64) encoded bundle, typically stored as
one or more local files, or in a Qt Resource.</p>
<p>You can call <a href="qsslcertificate.html#isNull">isNull</a>()
to check if your certificate is null. By default, QSslCertificate
constructs a null certificate. To check if the certificate is
valid, call <a href="qsslcertificate.html#isValid">isValid</a>(). A
null certificate is invalid, but an invalid certificate is not
necessarily null. If you want to reset all contents in a
certificate, call <a href="qsslcertificate.html#clear">clear</a>().</p>
<p>After loading a certificate, you can find information about the
certificate, its subject, and its issuer, by calling one of the
many accessor functions, including <a href="qsslcertificate.html#version">version</a>(), <a href="qsslcertificate.html#serialNumber">serialNumber</a>(), <a href="qsslcertificate.html#issuerInfo">issuerInfo</a>() and <a href="qsslcertificate.html#subjectInfo">subjectInfo</a>(). You can call
<a href="qsslcertificate.html#effectiveDate">effectiveDate</a>()
and <a href="qsslcertificate.html#expiryDate">expiryDate</a>() to
check when the certificate starts being effective and when it
expires. The <a href="qsslcertificate.html#publicKey">publicKey</a>() function returns
the certificate subject's public key as a <a href="qsslkey.html">QSslKey</a>. You can call <a href="qsslcertificate.html#issuerInfo">issuerInfo</a>() or <a href="qsslcertificate.html#subjectInfo">subjectInfo</a>() to get
detailed information about the certificate issuer and its
subject.</p>
<p>Internally, QSslCertificate is stored as an X509 structure. You
can access this handle by calling <a href="qsslcertificate.html#handle">handle</a>(), but the results are
likely to not be portable.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="SubjectInfo-enum" />QSslCertificate.SubjectInfo</h3><p>Describes keys that you can pass to <a href="qsslcertificate.html#issuerInfo">QSslCertificate.issuerInfo</a>()
or <a href="qsslcertificate.html#subjectInfo">QSslCertificate.subjectInfo</a>()
to get information about the certificate issuer or subject.</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QSslCertificate.Organization</tt></td>
<td class="topAlign"><tt>0</tt></td>
<td class="topAlign">"O" The name of the organization.</td>
</tr>
<tr>
<td class="topAlign"><tt>QSslCertificate.CommonName</tt></td>
<td class="topAlign"><tt>1</tt></td>
<td class="topAlign">"CN" The common name; most often this is used
to store the host name.</td>
</tr>
<tr>
<td class="topAlign"><tt>QSslCertificate.LocalityName</tt></td>
<td class="topAlign"><tt>2</tt></td>
<td class="topAlign">"L" The locality.</td>
</tr>
<tr>
<td class="topAlign">
<tt>QSslCertificate.OrganizationalUnitName</tt></td>
<td class="topAlign"><tt>3</tt></td>
<td class="topAlign">"OU" The organizational unit name.</td>
</tr>
<tr>
<td class="topAlign"><tt>QSslCertificate.CountryName</tt></td>
<td class="topAlign"><tt>4</tt></td>
<td class="topAlign">"C" The country.</td>
</tr>
<tr>
<td class="topAlign">
<tt>QSslCertificate.StateOrProvinceName</tt></td>
<td class="topAlign"><tt>5</tt></td>
<td class="topAlign">"ST" The state or province.</td>
</tr>
</table>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QSslCertificate" />QSslCertificate.__init__ (<i>self</i>, <a href="qiodevice.html">QIODevice</a>&#160;<i>device</i>, <a href="qssl.html#EncodingFormat-enum">QSsl.EncodingFormat</a>&#160;<i>format</i>&#160;=&#160;QSsl.Pem)</h3><p>Constructs a <a href="qsslcertificate.html">QSslCertificate</a>
by reading <i>format</i> encoded data from <i>device</i> and using
the first certificate found. You can later call <a href="qsslcertificate.html#isNull">isNull</a>() to see if <i>device</i>
contained a certificate, and if this certificate was loaded
successfully.</p>


<h3 class="fn"><a name="QSslCertificate-2" />QSslCertificate.__init__ (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>data</i>&#160;=&#160;QByteArray(), <a href="qssl.html#EncodingFormat-enum">QSsl.EncodingFormat</a>&#160;<i>format</i>&#160;=&#160;QSsl.Pem)</h3><p>Constructs a <a href="qsslcertificate.html">QSslCertificate</a>
by parsing the <i>format</i> encoded <i>data</i> and using the
first available certificate found. You can later call <a href="qsslcertificate.html#isNull">isNull</a>() to see if <i>data</i>
contained a certificate, and if this certificate was loaded
successfully.</p>


<h3 class="fn"><a name="QSslCertificate-3" />QSslCertificate.__init__ (<i>self</i>, <a href="qsslcertificate.html">QSslCertificate</a>&#160;<i>other</i>)</h3><p>Constructs an identical copy of <i>other</i>.</p>


<h3 class="fn"><a name="alternateSubjectNames" />dict-of-QSsl.AlternateNameEntryType-list-of-QString QSslCertificate.alternateSubjectNames (<i>self</i>)</h3><p>Returns the list of alternative subject names for this
certificate. The alternate subject names typically contain host
names, optionally with wildcards, that are valid for this
certificate.</p>
<p>These names are tested against the connected peer's host name,
if either the subject information for <a href="qsslcertificate.html#SubjectInfo-enum">CommonName</a> doesn't
define a valid host name, or the subject info name doesn't match
the peer's host name.</p>
<p><b>See also</b> <a href="qsslcertificate.html#subjectInfo">subjectInfo</a>().</p>


<h3 class="fn"><a name="clear" />QSslCertificate.clear (<i>self</i>)</h3><p>Clears the contents of this certificate, making it a null
certificate.</p>
<p><b>See also</b> <a href="qsslcertificate.html#isNull">isNull</a>().</p>


<h3 class="fn"><a name="digest" /><a href="qbytearray.html">QByteArray</a> QSslCertificate.digest (<i>self</i>, <a href="qcryptographichash.html#Algorithm-enum">QCryptographicHash.Algorithm</a>&#160;<i>algorithm</i>&#160;=&#160;QCryptographicHash.Md5)</h3><p>Returns a cryptographic digest of this certificate. By default,
an MD5 digest will be generated, but you can also specify a custom
<i>algorithm</i>.</p>


<h3 class="fn"><a name="effectiveDate" /><a href="qdatetime.html">QDateTime</a> QSslCertificate.effectiveDate (<i>self</i>)</h3><p>Returns the date-time that the certificate becomes valid, or an
empty <a href="qdatetime.html">QDateTime</a> if this is a null
certificate.</p>
<p><b>See also</b> <a href="qsslcertificate.html#expiryDate">expiryDate</a>().</p>


<h3 class="fn"><a name="expiryDate" /><a href="qdatetime.html">QDateTime</a> QSslCertificate.expiryDate (<i>self</i>)</h3><p>Returns the date-time that the certificate expires, or an empty
<a href="qdatetime.html">QDateTime</a> if this is a null
certificate.</p>
<p><b>See also</b> <a href="qsslcertificate.html#effectiveDate">effectiveDate</a>().</p>


<h3 class="fn"><a name="fromData" />list-of-QSslCertificate QSslCertificate.fromData (<a href="qbytearray.html">QByteArray</a>&#160;<i>data</i>, <a href="qssl.html#EncodingFormat-enum">QSsl.EncodingFormat</a>&#160;<i>format</i>&#160;=&#160;QSsl.Pem)</h3><p>Searches for and parses all certificates in <i>data</i> that are
encoded in the specified <i>format</i> and returns them in a list
of certificates.</p>
<p><b>See also</b> <a href="qsslcertificate.html#fromDevice">fromDevice</a>().</p>


<h3 class="fn"><a name="fromDevice" />list-of-QSslCertificate QSslCertificate.fromDevice (<a href="qiodevice.html">QIODevice</a>&#160;<i>device</i>, <a href="qssl.html#EncodingFormat-enum">QSsl.EncodingFormat</a>&#160;<i>format</i>&#160;=&#160;QSsl.Pem)</h3><p>Searches for and parses all certificates in <i>device</i> that
are encoded in the specified <i>format</i> and returns them in a
list of certificates.</p>
<p><b>See also</b> <a href="qsslcertificate.html#fromData">fromData</a>().</p>


<h3 class="fn"><a name="fromPath" />list-of-QSslCertificate QSslCertificate.fromPath (QString&#160;<i>path</i>, <a href="qssl.html#EncodingFormat-enum">QSsl.EncodingFormat</a>&#160;<i>format</i>&#160;=&#160;QSsl.Pem, <a href="qregexp.html#PatternSyntax-enum">QRegExp.PatternSyntax</a>&#160;<i>syntax</i>&#160;=&#160;QRegExp.FixedString)</h3><p>Searches all files in the <i>path</i> for certificates encoded
in the specified <i>format</i> and returns them in a list.
<i>must</i> be a file or a pattern matching one or more files, as
specified by <i>syntax</i>.</p>
<p>Example:</p>
<pre class="cpp">
 <a href="qtcore.html#foreach">foreach</a> (<span class="keyword">const</span> <span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span> <span class="operator">&amp;</span>cert<span class="operator">,</span> <span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span><span class="operator">.</span>fromPath(<span class="string">"C:/ssl/certificate.*.pem"</span><span class="operator">,</span> <span class="type"><a href="qssl.html">QSsl</a></span><span class="operator">.</span>Pem<span class="operator">,</span>
                                                          <span class="type"><a href="qregexp.html">QRegExp</a></span><span class="operator">.</span>Wildcard)) {
     <a href="qtcore.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> cert<span class="operator">.</span>issuerInfo(<span class="type"><a href="qsslcertificate.html">QSslCertificate</a></span><span class="operator">.</span>Organization);
 }
</pre>
<p><b>See also</b> <a href="qsslcertificate.html#fromData">fromData</a>().</p>


<h3 class="fn"><a name="handle" />int QSslCertificate.handle (<i>self</i>)</h3><p>Returns a pointer to the native certificate handle, if there is
one, or a null pointer otherwise.</p>
<p>You can use this handle, together with the native API, to access
extended information about the certificate.</p>
<p><b>Warning:</b> Use of this function has a high probability of
being non-portable, and its return value may vary from platform to
platform or change from minor release to minor release.</p>


<h3 class="fn"><a name="isNull" />bool QSslCertificate.isNull (<i>self</i>)</h3><p>Returns true if this is a null certificate (i.e., a certificate
with no contents); otherwise returns false.</p>
<p>By default, <a href="qsslcertificate.html">QSslCertificate</a>
constructs a null certificate.</p>
<p><b>See also</b> <a href="qsslcertificate.html#isValid">isValid</a>() and <a href="qsslcertificate.html#clear">clear</a>().</p>


<h3 class="fn"><a name="issuerInfo" />QString QSslCertificate.issuerInfo (<i>self</i>, <a href="qsslcertificate.html#SubjectInfo-enum">SubjectInfo</a>&#160;<i>info</i>)</h3><p>Returns the issuer information for the <i>subject</i> from the
certificate, or an empty string if there is no information for
<i>subject</i> in the certificate.</p>
<p><b>See also</b> <a href="qsslcertificate.html#subjectInfo">subjectInfo</a>().</p>


<h3 class="fn"><a name="issuerInfo-2" />QString QSslCertificate.issuerInfo (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>tag</i>)</h3><p>Returns the issuer information for <i>tag</i> from the
certificate, or an empty string if there is no information for
<i>tag</i> in the certificate.</p>
<p><b>See also</b> <a href="qsslcertificate.html#subjectInfo">subjectInfo</a>().</p>


<h3 class="fn"><a name="isValid" />bool QSslCertificate.isValid (<i>self</i>)</h3><p>Returns true if this certificate is valid; otherwise returns
false.</p>
<p>Note: Currently, this function checks that the current data-time
is within the date-time range during which the certificate is
considered valid, and checks that the certificate is not in a
blacklist of fraudulent certificates.</p>
<p><b>See also</b> <a href="qsslcertificate.html#isNull">isNull</a>().</p>


<h3 class="fn"><a name="publicKey" /><a href="qsslkey.html">QSslKey</a> QSslCertificate.publicKey (<i>self</i>)</h3><p>Returns the certificate subject's public key.</p>


<h3 class="fn"><a name="serialNumber" /><a href="qbytearray.html">QByteArray</a> QSslCertificate.serialNumber (<i>self</i>)</h3><p>Returns the certificate's serial number string in decimal
format. In case the serial number cannot be converted to decimal
format (i.e. if it is bigger than 4294967295, which means it does
not fit into 4 bytes), its hexadecimal version is returned.</p>


<h3 class="fn"><a name="subjectInfo" />QString QSslCertificate.subjectInfo (<i>self</i>, <a href="qsslcertificate.html#SubjectInfo-enum">SubjectInfo</a>&#160;<i>info</i>)</h3><p>Returns the information for the <i>subject</i>, or an empty
string if there is no information for <i>subject</i> in the
certificate.</p>
<p><b>See also</b> <a href="qsslcertificate.html#issuerInfo">issuerInfo</a>().</p>


<h3 class="fn"><a name="subjectInfo-2" />QString QSslCertificate.subjectInfo (<i>self</i>, <a href="qbytearray.html">QByteArray</a>&#160;<i>tag</i>)</h3><p>Returns the subject information for <i>tag</i>, or an empty
string if there is no information for <i>tag</i> in the
certificate.</p>
<p><b>See also</b> <a href="qsslcertificate.html#issuerInfo">issuerInfo</a>().</p>


<h3 class="fn"><a name="toDer" /><a href="qbytearray.html">QByteArray</a> QSslCertificate.toDer (<i>self</i>)</h3><p>Returns this certificate converted to a DER (binary) encoded
representation.</p>


<h3 class="fn"><a name="toPem" /><a href="qbytearray.html">QByteArray</a> QSslCertificate.toPem (<i>self</i>)</h3><p>Returns this certificate converted to a PEM (Base64) encoded
representation.</p>


<h3 class="fn"><a name="version" /><a href="qbytearray.html">QByteArray</a> QSslCertificate.version (<i>self</i>)</h3><p>Returns the certificate's version string.</p>


<h3 class="fn"><a name="__eq__" />bool QSslCertificate.__eq__ (<i>self</i>, <a href="qsslcertificate.html">QSslCertificate</a>&#160;<i>other</i>)</h3><h3 class="fn"><a name="__ne__" />bool QSslCertificate.__ne__ (<i>self</i>, <a href="qsslcertificate.html">QSslCertificate</a>&#160;<i>other</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;snapshot-4.9.5-9eb6aac99275 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.3</td></tr></table></div></address></body></html>